#include "logfile.h"

FILE * logFile::g_log_fp = 0;

logFile::logFile()
{

}

void logFile::myMessageOutput(QtMsgType type, const QMessageLogContext &conttext, const QString &msg)
{
    QByteArray localMsg = msg.toLocal8Bit();
    switch (type) {
    case QtDebugMsg:
        fprintf(g_log_fp, "Debug: %s (%s:%u, %s)\n",
                localMsg.constData(),
                conttext.file,conttext.line,conttext.function);
        break;
    case QtWarningMsg:
        fprintf(g_log_fp, "Warning: %s (%s:%u, %s)\n",
                localMsg.constData(),
                conttext.file,conttext.line,conttext.function);
        break;
    case QtCriticalMsg:
        fprintf(g_log_fp, "Critical: %s (%s:%u, %s)\n",
                localMsg.constData(),
                conttext.file,conttext.line,conttext.function);
        break;
    case QtFatalMsg:
        fprintf(g_log_fp, "Fatal: %s (%s:%u, %s)\n",
                localMsg.constData(),
                conttext.file,conttext.line,conttext.function);
        abort();
        break;
    case QtInfoMsg:
        fprintf(g_log_fp, "Info: %s (%s:%u, %s)\n",
                localMsg.constData(),
                conttext.file,conttext.line,conttext.function);
        break;
    default:
        break;
    }
}

